//UserDefinedException.java
package com.ylaihui.exception;

public class UserDefinedException {
	public static void main(String[] args) {
		try {
			Student1 stu = new Student1();
			stu.register(-1000);
		} catch (Exception e) {
//			e.printStackTrace();
			System.out.println(e.getMessage());
		}
	}
}

class Student1{
	int id;
	public void register(int id) throws Exception{
		if(id > 0)
			this.id = id;
		else
			throw new DataNotValidException("id is not valid!");
			// error
//			throw new String("id is not valid!");
	}
}
